import * as API from '@/api'

const state = {
  currentPosition: {},
  stationData: {},
  heartCard: {},
  rechargeGas: {},
  orderTabIndex: 0,
  selectCity: '',
  cityList: '',
  orderType: '',
};

// 获取state的数据
const getters = {
  stationData: (state) => state.stationData,
  currentPosition: (state) => state.currentPosition,
  heartCard: (state) => state.heartCard,
  orderTabIndex: (state) => state.orderTabIndex,
  selectCity: (state) => state.selectCity,
  cityList: (state) => state.cityList,
  rechargeGas: (state) => state.rechargeGas,
  orderType: (state) => state.orderType
};

// 更新state的数据
const mutations = {
  StationData(state, data) {
    state.stationData = data;
  },
  CurrentPosition(state, data) {
    state.currentPosition = data;
  },
  HeartCard(state, data) {
    state.heartCard = data;
  },
  RechargeGas(state, data) {
    state.rechargeGas = data;
  },
  OrderTabIndex(state, data) {
    state.orderTabIndex = data;
  },
  OrderType(state, data) {
    state.orderType = data;
  },
  SelectCity(state, data) {
    state.selectCity = data;
  },
  cityList(state, data) {
    state.cityList = data;
  },
};

// 更新state数据的动作
const actions = {
  getStationData({ commit }, params) {
    commit("StationData", params);
  },
  setCurrentPosition({ commit }, params) {
    commit("CurrentPosition", params);
  },
  // 一键充值
  setHeartCard({ commit }, params) {
    commit("HeartCard", params);
  },
  // 油卡充值
  setRechargeGas({ commit }, params) {
    commit("RechargeGas", params);
  },
  // 订单页面tab标签
  OrderTabIndex({ commit }, params) {
    commit("OrderTabIndex", params);
  },
  SetOrderType({ commit }, params) {
    commit("OrderType", params);
  },
  SetSelectCity({ commit }, params) {
    commit("SelectCity", params);
  },
  SetCityList({ commit }, params) {
    commit("cityList", params);
  },
};


export default { state, getters, mutations, actions };
